package com.whj.servicedriveruser.controller;


import com.whj.internalcommon.dto.DriverCarBindingRelationship;
import com.whj.internalcommon.dto.ResponseResult;
import com.whj.servicedriveruser.service.IDriverCarBindingRelationshipService;
import com.whj.servicedriveruser.service.impl.DriverCarBindingRelationshipServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whj
 * @since 2023-01-13
 */
@RestController
@RequestMapping("/driver-car-binding-relationship")
public class DriverCarBindingRelationshipController {

    @Autowired
    private IDriverCarBindingRelationshipService driverCarBindingRelationshipService;

    /**
     * 根据司机id和车辆id相互绑定
     * @param driverCarBindingRelationship 司机id和车辆id
     * @return
     */
    @PostMapping("/bind")
    public ResponseResult bind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverCarBindingRelationshipService.bind(driverCarBindingRelationship);
    }

    /**
     * 根据司机id和车辆id解除绑定
     * @param driverCarBindingRelationship 司机id和车辆id
     * @return
     */
    @PostMapping("/unbind")
    public ResponseResult unbind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverCarBindingRelationshipService.unbind(driverCarBindingRelationship);
    }

    /**
     * 根据司机id查询车辆信息
     *
     * @param driverPhone
     * @return
     */
    @GetMapping("/findMessage")
    public ResponseResult<DriverCarBindingRelationship> findMessage(@RequestParam String driverPhone){
        return driverCarBindingRelationshipService.findMessage(driverPhone);
    }
}
